package com.ga01.controller;

import com.ga01.entity.EvaItem;
import com.ga01.service.EvaItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/eva-items")
public class EvaItemController {

    @Autowired
    private EvaItemService evaItemService;

    @GetMapping
    public List<EvaItem> getAllEvaItems() {
        return evaItemService.list();
    }

    @GetMapping("/{id}")
    public EvaItem getEvaItemById(@PathVariable Integer id) {
        return evaItemService.getById(id);
    }

    @PostMapping
    public boolean addEvaItem(@RequestBody EvaItem evaItem) {
        return evaItemService.save(evaItem);
    }

    @PutMapping
    public boolean updateEvaItem(@RequestBody EvaItem evaItem) {
        return evaItemService.updateById(evaItem);
    }

    @DeleteMapping("/{id}")
    public boolean deleteEvaItem(@PathVariable Integer id) {
        return evaItemService.removeById(id);
    }
}